# +--------------------------
# | User: zq                -
# | Version: python3.7      -
# | Time: 2020-03-12 16:51                
# +--------------------------
# 1. twitter Timeline
# 导入线程池
from concurrent.futures import ThreadPoolExecutor
import time


def sleep_task(sleep_time, name):
    print("{} {} s".format(name, sleep_time))
    time.sleep(sleep_time)


executor = ThreadPoolExecutor(max_workers=2)
task1 = executor.submit(sleep_task, 2, 'booby')  # 这里的传值注意,是一个一个传值的
task2 = executor.submit(sleep_task, 3, 'booby2')  # 这里的传值注意,是一个一个传值的
task3 = executor.submit(sleep_task, 3, 'booby3')  # 这里的传值注意,是一个一个传值的

cancel_status = task1.cancel()  # 1. 运行中的程序是无法取消的
print(task1.cancel())
print(task2.cancel())
print(task3.cancel())

# print(cancel_status)

# time.sleep(2)
# print(task1.done())
